using System;
using Microsoft.SPOT;
using EmbeddedWebserver.Core;
using EmbeddedWebserver.Core.Handlers.Abstract;
using EmbeddedWebserver.Core.Helpers;

namespace HttpIntfLib
{
    class SamplePostHandler:HandlerBase
    {
        #region Non-public members

        protected override void ProcessRequestWorker(HttpContext pContext)
        {
            StringDictionary dict = pContext.Request.GetPostRequestParameters();

            StringBuilder builder = new StringBuilder();
            builder.Append("{ \"key\": \"");
            builder.Append(dict.ContainsKey("key") ? dict["key"]: "null");
            builder.Append("\", ");
            builder.Append("\"value\": \"");
            builder.Append(dict.ContainsKey("value") ? dict["value"] : "null");
            builder.Append("\" }");
            pContext.Response.ResponseBody = builder.ToString();
            pContext.Response.ContentType = "application/json";
        }

        #endregion

        #region Constructors

        public SamplePostHandler() : base(HttpMethods.POST) { //TBD
        }

        #endregion
    }
}
